package xiaohu.day1.HJ20;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String input = in.nextLine();
            //验证长度
            if(input.length()<=8) {
                System.out.println("NG");
                continue;
            }
            //验证字符的种类数
            boolean[] condition = new boolean[4];
            for (int i=0; i<input.length(); i++) {
                char c = input.charAt(i);
                if (c>='a' && c<='z') {
                    condition[0] = true;
                    continue;
                }
                if (c>='A' && c<='Z') {
                    condition[1] = true;
                    continue;
                }
                if (c>='0' && c<='9') {
                    condition[2] = true;
                    continue;
                }
                if (c!=' ' && c!='\t') {
                    condition[3] = true;
                    continue;
                }
            }
            int count = 0;
            for (boolean tmp:condition) {
                if (tmp) ++count;
            }
            if (count < 3) {
                System.out.println("NG");
                continue;
            }
            //验证重复
            boolean isNG = false;
            for (int j=0; j<input.length()-3; j++) {
                //当有长度大于3的字符串重复、则必有长度等于三的字符串重复、故只需验证是否有长度等于三的字符串重复即可
                String sub = input.substring(j,j+3);
                String remain = input.substring(j+3);
                if (remain!=null && remain.contains(sub)) {
                    isNG = true;
                    break;
                }
            }
            if (isNG) {
                System.out.println("NG");
                continue;
            }

            System.out.println("OK");
        }
    }
}
